<SCRIPT LANGUAGE="JavaScript">  
    function validation()
    {
        var temp="";
        var alpha = /^[a-zA-Z0-9-_]*$/;
        var emailPattern = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        
        temp=document.getElementById('JobseekerUsername').value;
        if( temp.length < 6 || temp.length > 20 || !alpha.test(temp))
        {
            document.getElementById('JobseekerUsername').focus();
            document.getElementById('JobseekerUsername').style.backgroundColor='#FFC';
            alert('Username must be between 6 to 20 alphanumeric characters');
            document.getElementById('JobseekerUsername').style.backgroundColor='#FFF';
            return false;             
        }
        else
        {
            if(document.getElementById('kembar'))
            {
                if (document.getElementById('kembar').value=='yes')
                {
                    document.getElementById('JobseekerUsername').focus();
                    document.getElementById('JobseekerUsername').style.backgroundColor='#FFC';
                    alert('This Username is already taken, please choose another');
                    document.getElementById('JobseekerUsername').style.backgroundColor='#FFF';
                    return false;                
                }                
            }
        }
        
        temp=document.getElementById('JobseekerPassword').value;
        if( temp.length < 6 || temp.length > 20 || !alpha.test(temp))
        {
            document.getElementById('JobseekerPassword').focus();
            document.getElementById('JobseekerPassword').style.backgroundColor='#FFC';
            alert('Password must be between 6 to 20 alphanumeric characters');
            document.getElementById('JobseekerPassword').style.backgroundColor='#FFF';
            return false;             
        }
        
        if( temp!=document.getElementById('JobseekerPassword2').value )
        {
            document.getElementById('JobseekerPassword2').focus();
            document.getElementById('JobseekerPassword2').style.backgroundColor='#FFC';
            alert("Your Confirm Password doesn't match");
            document.getElementById('JobseekerPassword2').style.backgroundColor='#FFF';
            return false;             
        }
        
        temp=document.getElementById('JobseekerEmail').value;
        if( !emailPattern.test(temp) )
        {
            document.getElementById('JobseekerEmail').focus();
            document.getElementById('JobseekerEmail').style.backgroundColor='#FFC';
            alert('Please enter a valid email');
            document.getElementById('JobseekerEmail').style.backgroundColor='#FFF';
            return false;             
        }        

        temp=document.getElementById('JobseekerFirstName').value;
        if( temp.length==0 )
        {
            document.getElementById('JobseekerFirstName').focus();
            document.getElementById('JobseekerFirstName').style.backgroundColor='#FFC';
            alert("Please fill your first name");
            document.getElementById('JobseekerFirstName').style.backgroundColor='#FFF';
            return false;             
        }
        
        temp=document.getElementById('JobseekerGender').value;
        if( temp.length==0 )
        {
            document.getElementById('JobseekerGender').focus();
            document.getElementById('JobseekerGender').style.backgroundColor='#FFC';
            alert('Please choose the gender of yours');
            document.getElementById('JobseekerGender').style.backgroundColor='#FFF';
            return false;             
        }
        
        if(temp=='Male' && ( document.getElementById('JobseekerSalution').value=='Ms.' || document.getElementById('JobseekerSalution').value=='Mrs.') )
        {
            document.getElementById('JobseekerGender').focus();
            document.getElementById('JobseekerGender').style.backgroundColor='#FFC';
            alert('Your type of Gender and Salution are missmatch');
            document.getElementById('JobseekerGender').style.backgroundColor='#FFF';
            return false;
        }
        if(temp=='Female' && document.getElementById('JobseekerSalution').value=='Mr.' )
        {
            document.getElementById('JobseekerGender').focus();
            document.getElementById('JobseekerGender').style.backgroundColor='#FFC';
            alert('Your type of Gender and Salution are missmatch');
            document.getElementById('JobseekerGender').style.backgroundColor='#FFF';
            return false;
        }   
        
        
        var da=document.getElementById('JobseekerDateOfBirthDay').value;
        var mo=document.getElementById('JobseekerDateOfBirthMonth').value;
        var ye=document.getElementById('JobseekerDateOfBirthYear').value;      
        if( da.length==0 || mo.lenth==0 || ye.length==0 )
        {
            document.getElementById('JobseekerDateOfBirthDay').focus();
            document.getElementById('JobseekerDateOfBirthDay').style.backgroundColor='#FFC';
            document.getElementById('JobseekerDateOfBirthMonth').style.backgroundColor='#FFC';
            document.getElementById('JobseekerDateOfBirthYear').style.backgroundColor='#FFC';
            alert("Please fill your date of birth");
            document.getElementById('JobseekerDateOfBirthDay').style.backgroundColor='#FFF';
            document.getElementById('JobseekerDateOfBirthMonth').style.backgroundColor='#FFF';
            document.getElementById('JobseekerDateOfBirthYear').style.backgroundColor='#FFF';
            return false;
        }
        
        temp=document.getElementById('JobseekerEthnic').value;
        if( temp.length==0 )
        {
            document.getElementById('JobseekerEthnic').focus();
            document.getElementById('JobseekerEthnic').style.backgroundColor='#FFC';
            alert("Please fill ethnic");
            document.getElementById('JobseekerEthnic').style.backgroundColor='#FFF';
            return false;             
        }

        temp=document.getElementById('JobseekerCityId').value;
        if( temp.length==0 )
        {
            document.getElementById('JobseekerCityId').focus();
            document.getElementById('JobseekerCityId').style.backgroundColor='#FFC';
            alert("Please choose your city of residence");
            document.getElementById('JobseekerCityId').style.backgroundColor='#FFF';
            return false;             
        }
        
        temp=document.getElementById('security_code').value;
        if( temp != document.getElementById('security_code2').value)
        {
            document.getElementById('security_code').focus();
            document.getElementById('security_code').style.backgroundColor='#FFC';
            alert('Security code is not valid');
            document.getElementById('security_code').style.backgroundColor='#FFF';
            return false;             
        }        
                                        
    }
    
</SCRIPT>
    
<?php 

echo "<div class='form'>";
echo "<h2> Formulir Daftar Pencari kerja </h2>";
echo "<hr color='#2A7EF7'>";
if(empty($sukses))
{
        $RandomStr = md5(microtime());// md5 to generate the random string
        $ResultStr = substr($RandomStr,0,5);//trim 5 digit
        $_SESSION['key']=$ResultStr;       
        
        echo "<div class='kotak2'>"; 
        echo $form->create('Jobseeker',array('div'=>false, 'action'=>'signup','onsubmit'=>'return validation();')); 
        
        echo "<form >";
        
            echo "<div class='input'><label> &nbsp </label>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<span class='red'>*</span> <b>Required Field</b></div>";
            
            echo $form->input('username',array ('label'=>'Nama User','maxLength'=>'20','after'=>"<span class='red'><sup>*</sup></span>"));          

            echo "<div class='result' id='result'></div>";                    
            echo $ajax->observeField('JobseekerUsername', array(                
                                        'url' => array('controller'=> 'jobseekers', 'action' => 'checkname'), 
                                        'update' => 'result','frequency' => 0.2)
                                        );
                                
            echo $form->input('password',array ('maxLength'=>'20','after'=>"<span class='red'><sup>*</sup></span>"));
            echo $form->input('password2',array ('label'=>'Konfirmasi Password','type'=>'password','maxLength'=>'20','after'=>"<span class='red'><sup>*</sup></span>"));
            echo "<div class='input'>";
            echo $form->input('email', array ('div'=>false,'maxLength'=>'40','after'=>"<span class='red'>*</span>"));                                           
            echo "<br><label> &nbsp </label> <span class='info'> - Digunakan untuk memverifikasi account Anda </span>";
            echo "</div>";
            echo $form->input('salution', array( 'label'=>'Sapaan','empty'=>'', 'options'=>array('Mr.'=>'Mr.','Ms.'=>'Ms.','Mrs.'=>'Mrs.','Dr.'=>'Dr.') ) );
            echo $form->input('first_name',array ('label'=>'Nama Awal','maxLength'=>'20','after'=>"<span class='red'><sup>*</sup></span>"));
            echo $form->input('last_name',array ('label'=>'Nama Akhir','Family/Last Name','maxLength'=>'20'));
            echo $form->input('martial_status', array('label'=>'Kebangsaan', 'empty'=>'', 'options'=>array('WNI'=>'WNI','WNA'=>'WNA') ) );
            echo $form->input('gender', array( 'label'=>'Jenis Kelamin','empty'=>'', 'options'=>array('Male'=>'Male','Female'=>'Female'),'after'=>"<span class='red'><sup>*</sup></span>" ) );
            $maxyear=date("Y")-10;
            $minyear=$maxyear-30;
            echo $form->input('date_of_birth',array('label'=>'Tanggal Lahir', 'dateFormat'=>'DMY', 'empty'=>' ', 'selected'=>'empty', 'minYear'=>$minyear, 'maxYear'=>$maxyear,'after'=>"<span class='red'><sup>*</sup></span>"));
            echo $form->input('City',array( 'empty'=>'','label'=>'Kota','after'=>"<span class='red'><sup>*</sup></span>" ));
			echo $form->input('Skill',array('id'=>'list_skill','label'=>'Kemampuan','style'=>'height:200px;width:150px;'));
            echo "<br>";
            $baseurl = current(split("index", $_SERVER['PHP_SELF']));
            echo "<div class='input'><label>&nbsp</label><img src='".$baseurl."CaptchaSecurityImages.php?code=".$_SESSION['key']."'></div>";
            echo "<div class='input'><label>Security Code</label><input type='text' id='security_code' size=5><span class='red'><sup>*</sup></span></div><input type='hidden' id='security_code2' value='".$_SESSION['key']."'>";
            
            echo "<div class='input'><label> &nbsp </label><input type='submit' value='Submit'></div>";
        echo "</form>";
        echo "</div>";
        echo " :. Jika Anda sudah memiliki account di IT-jobz.com. silahkan login ";
        echo $html->link('[ Here ]',array('controller'=>'jobseekers','action'=>'login'));
}
else
{
    echo ":. Harap verifikasi email Anda untuk mengaktifkan account Anda, dan kemudian ";
    echo $html->link('[ Login ]',array('controller'=>'jobseekers','action'=>'login'));
    echo " to IT-Jobz.com";
}
echo "</div>";

?>
